#ifndef TILEMAP_H
#define TILEMAP_H

#include <vector>
#include <fstream>
#include <iostream>
#include <queue>

#include "utility.h"



// The whole code is around that data structure, i don't want to pass it in every 2nd function.
class TileMap
{
	public:
		static TileMap* getInstance ();

		Coord getSizeInCoord ();

		int countNum (const int num) const;
		PrimTileMap filter (const int filterableNum) const;
		PrimTileMap inverseFilter (const int filterableNum) const;

        void insertBlockToFill (const PrimTileMap& block);
        void insertBlockFromFill (const PrimTileMap& block);

        void insertCoordToFill (const Coord& coord);
        void insertCoordFromFill (const Coord& coord);

        bool isToFillEmpty () {return toFill.empty();}
        bool isFromFillEmpty () {return fromFill.empty();}

		int countSteps ();
		void doStep ();
		void writeSteps (std::ostream& os) const;
		void writeTileMap (std::ostream& os) const;


	private:
		PrimTileMap tileMap;
		static TileMap* instance;

		std::vector<Coord> unMovablePoints;
        std::vector<StepType> stepsDone;
        std::vector<StepType> stepsToDo;

        std::queue<Coord> toFill;
        std::queue<Coord> fromFill;
		TileMap ();
		void read (std::ifstream& iStream);
};

#endif // TILEMAP_H
